package com.hanqian.kepler.core.dao.primary.core;

import com.hanqian.kepler.common.base.dao.BaseDao;
import com.hanqian.kepler.core.entity.primary.core.TargetDescZan;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * newFile
 * ============================================================================
 * author : dzw
 * createDate:  2021/1/11 。
 * ============================================================================
 */
public interface TargetDescZanDao extends BaseDao<TargetDescZan, String> {

	/**
	 * 获取某个人再某个指标下赞过的描述ids
	 */
	@Query(value = "SELECT desc1.id FROM kepler_target_zan zan inner join kepler_target_desc desc1 on zan.targetDesc_id=desc1.id and zan.versionIndex=desc1.versionIndex left join kepler_target target on desc1.target_id=target.id where zan.state='Enable' and target.id=:targetId and zan.creator_id=:userId", nativeQuery = true)
	List<String> findZanDescIds(@Param("targetId") String targetId, @Param("userId") String userId);

}
